package com.wkbb.sports.thread;

import com.wkbb.common.dto.ResultDTO;
import com.wkbb.sports.feign.BasicFeignService;
import com.wkbb.sports.service.AchievementService;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;

@Slf4j
public class AchievementScoreImportTask implements Callable<ResultDTO> {

	private AchievementService achievementService;

	private BasicFeignService basicFeignService;

	private Integer type;

	private Long orgId;

	private Long termId;

	private List<Object[]> titleList;

	private List<Object[]> dataList;

	private Integer currentRow;

	public AchievementScoreImportTask(AchievementService achievementService, BasicFeignService basicFeignService, Integer type, Long orgId, Long termId, List<Object[]> titleList, List<Object[]> dataList, Integer currentRow) {
		this.achievementService = achievementService;
		this.basicFeignService = basicFeignService;
		this.type = type;
		this.orgId = orgId;
		this.termId = termId;
		this.titleList = titleList;
		this.dataList = dataList;
		this.currentRow = currentRow;
	}

	@Override
	public ResultDTO<Map<String,Object>> call() throws Exception {
		log.info("*******AchievementScoreImportTask begin**********");

		ResultDTO resultDTO = null;
		try {
			log.info("---当前线程----:{}---开启启动---orgId:{} termId:{} type:{} currentRow:{}",Thread.currentThread().getName(),orgId,termId,type);
			achievementService.uploadAchievement(basicFeignService,type,orgId,termId,titleList,dataList,currentRow);

		} catch (Exception e) {
			log.error("******AchievementScoreImportTask******", e);
		}
		log.info("*******AchievementScoreImportTask end**********");
		return resultDTO;
	}
}
